<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.lmpop.trade.ts_category.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.lmpop.frame.util.PageTools"%>
<%
	request.setCharacterEncoding("UTF-8");
	Map ts_category = new Hashtable();
	Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
	String s_title = "";
	if(request.getParameter("s_title")!=null){
		  s_title = request.getParameter("s_title");
		  ts_category.put("cat_name",s_title);
	}
	ts_category.put("class_type","2");
	
	String up_classId="",break_cat_id="";
	if (request.getParameter("up_classId") != null) {
		up_classId = request.getParameter("up_classId");
		if(!up_classId.equals("000000000000000")){
			break_cat_id=ts_categoryInfo.getUp_cat_id(up_classId);
		}
	}else{
	    up_classId="000000000000000";
	}
	ts_category.put("up_cat_id",up_classId);
	
	
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
 
	List list = ts_categoryInfo.getListByPage(ts_category,Integer.parseInt(iStart),limit);
	int counter = ts_categoryInfo.getCountByObj(ts_category);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?s_title="+s_title+"&up_classId="+up_classId+"&iStart=",Integer.parseInt(iStart),limit);
%>
<html>
  <head>
    <title>商品分类属性管理</title>
 
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
    <script language="javascript" type="text/javascript" src="js_categoryattr.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>商品分类属性管理</h1>
			</td>
			<td>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left">
				分类名称：<input name="s_title" id="s_title" type="text" onBlur="this.value=ignoreSpaces(this.value);"	 />&nbsp;&nbsp;
				<input name="searchInfo" type="button" value="查询" onclick="searchForm()"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
		    <%
			if(!up_classId.equals("000000000000000")){        
			%>
				<input type="button" name="ret" onclick="window.location.href='index.jsp?class_type=2&up_classId=<%=break_cat_id%>'" value="返回" class="buttab"/>		   
		   <%}%>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
		  	<th>分类名称</th>	  	
		  	<th>是否显示</th>
	  		<th width="20%">查看/添加商品属性</th>
		</tr>
		
		
		<% 
			Hashtable map = new Hashtable();
			for(int i=0;i<list.size();i++){
				map = (Hashtable)list.get(i);
				String cat_id="",cat_name="",up_cat_id="",cat_level="",g_class_type="",
					is_dis="",sort_no="",rsrv_str1="",rsrv_str2="",rsrv_str3="",remark="";
				if(map.get("cat_id")!=null) cat_id = map.get("cat_id").toString();
				if(map.get("cat_name")!=null) cat_name = map.get("cat_name").toString();
				if(map.get("up_cat_id")!=null) up_cat_id = map.get("up_cat_id").toString();
				if(map.get("cat_level")!=null) cat_level = map.get("cat_level").toString();
				if(map.get("class_type")!=null) g_class_type = map.get("class_type").toString();
				if(map.get("is_dis")!=null) is_dis = map.get("is_dis").toString();
				if(map.get("sort_no")!=null) sort_no = map.get("sort_no").toString();
 
				String	distring="";
				if(is_dis.equals("0")){
 
					distring  ="显示";
				}else if(is_dis.equals("1")){
			  
		distring  ="不显示";
				}	
				Boolean hasDown =  ts_categoryInfo.checkSonById(cat_id);				 

		  %>
		
		<tr>
						
		  	<td>
		  		&nbsp;
		  		<%
		  		 if(hasDown){
		  		%>
 
		  		<input type="hidden" name="hasdown<%=i%>" value="1" id="hasdown<%=i%>" />
		  		<a href="index.jsp?up_classId=<%=cat_id%>" title="查看该分类下级"><img src="/program/admin/images/1.gif" border="0" style="cursor:pointer;"/>
		  			<%=cat_name%>	
		  		</a>
		  		<%}else{%>
		  			<%=cat_name%>
		  		<%}%>
		  		</td>
		  			  	
		  	<td>&nbsp;<%=distring%></td>
         	
         	<td width="20%">
         	&nbsp;
         	<%
		  		 if(hasDown){
		  		%>
 
			  <a href="index.jsp?up_classId=<%=cat_id%>">查看下级分类 </a>        
         <%} else {%>
           <a href="classAttr.jsp?cat_id=<%=cat_id%>&up_cat_id=<%=up_cat_id%>">分类属性管理</a>   
         <%}%>
       
        </td>
                                                                	  
	  </tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
		<%
			if(!up_classId.equals("000000000000000")){        
        %>
		   
         <input type="button" name="ret" onclick="window.location.href='index.jsp?class_type=2&up_classId=<%=break_cat_id%>'" value="返回" class="buttab"/>
		   
		<%}%>

			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0"  class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	    <input type="hidden" name="up_classId" value="<%=up_classId%>" id="up_classId" />  
	 	  </form>
</body>

</html>
